
clear

cd "D:\data_replication"

import delimited estimation\4_demand_estimation\pc8plus_i_k.csv, clear 
keep v1 v3
rename v1 product_id
rename v3 k
save estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k.dta, replace


use estimation\4_demand_estimation\4_cobb_douglas_weights\weights_product_id.dta, clear
merge m:1 product_id using estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k.dta
keep k year quarter declarant s_20_product_id s_80_product_id
drop if k == 0
drop if k == .
order k year quarter declarant s_20_product_id s_80_product_id
sort k year quarter declarant
rename s_20_product_id s_20_k
rename s_80_product_id s_80_k
save estimation\4_demand_estimation\4_cobb_douglas_weights\weights_k.dta, replace
export delimited using estimation\4_demand_estimation\4_cobb_douglas_weights\weights_k.csv, replace

rm estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k.dta
